package com.media.themovieworld.api;

import java.util.HashMap;

import com.media.themovieworld.util.AppSettingPrefference;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.telephony.TelephonyManager;

public class ApiParams {
	public static final String DOWNLOAD_BASE_URL = "http://117.120.31.83:7001/mobile/download?";
	public static final int DIALOG_PROCESSING_PROGRESS = 100;
	public static final String DEVICE_CONNECTED = "deviceConnected";
	public static final String GET_AUDIO = "getAudio";
	public static final String GET_CATEGORY = "getCategory";
	public static final String GET_IMAGE = "getImage";
	public static final String GET_NEWS = "getNews";
	public static final String GET_VIDEO = "getVideo";
	public static final String GET_PAYMENT = "payment";
	public static final String GET_ADVERTISE = "getListAdvertise";
	public static final String GET_GAME = "getGame";
	public static final String GET_FILM = "getFilm";
	public static final String VERSION_ID = "3";	
	
	//Define
	public static String CATEGORY_TYPE = "13";
	/**
	 * 
	 * @param name
	 * @param categoryId
	 * @param orderBy
	 * @param minRow
	 * @param maxRow
	 * @return
	 */
	public static RequestModel GetPicturesParams(String name, String categoryId,String orderBy,int minRow,int maxRow) {
		if (categoryId != null) {
			RequestModel requestModel = new RequestModel();
			final HashMap<String, String> map = new HashMap<String, String>();
			map.put("name", name);
			map.put("categoryId", categoryId);
			map.put("orderBy", orderBy);
			map.put("minRow", String.valueOf(minRow));
			map.put("maxRow", String.valueOf(maxRow));
			requestModel.api = GET_IMAGE;
			requestModel.params = map;
			return requestModel;
		}
		return null;
	}
	/**
	 * 
	 * @param name
	 * @param categoryId
	 * @param orderBy
	 * @param minRow
	 * @param maxRow
	 * @return
	 */
	public static RequestModel getVideoParams(String name, String categoryId,String orderBy,int minRow,int maxRow) {
		if(categoryId!=null ) {
			RequestModel requestModel = new RequestModel();
			final HashMap<String, String> map = new HashMap<String, String>();
			map.put("name", name);
			map.put("categoryId", categoryId);
			map.put("orderBy", orderBy);
			map.put("minRow", String.valueOf(minRow));
			map.put("maxRow", String.valueOf(maxRow));
			requestModel.api = GET_VIDEO;
			requestModel.params = map;
			return requestModel;
		}
		return null;
	}
	
	public static RequestModel getFilmParams(String name,String categoryId,int orderBy,int type,int minRow,int maxRow,String language){
		if(categoryId!=null){
			RequestModel requestModel = new RequestModel();
			final HashMap<String, String> map = new HashMap<String, String>();
			map.put("name", name);
			map.put("categoryId", categoryId);
			map.put("orderBy", String.valueOf(orderBy));
			map.put("type", String.valueOf(type));
			map.put("versionId", VERSION_ID);
			map.put("minRow", String.valueOf(minRow));
			map.put("maxRow", String.valueOf(maxRow));
			map.put("language", language);
			requestModel.api = GET_FILM;
			requestModel.params = map;
			return requestModel;
		}
		return null;
	}
	/**
	 * 
	 * @param name
	 * @param categoryId
	 * @param orderBy
	 * @param minRow
	 * @param maxRow
	 * @return
	 */
	public static RequestModel getGameAndAppParams(String name, String categoryId,String orderBy,int minRow,int maxRow) {
		RequestModel requestModel = new RequestModel();
		final HashMap<String, String> map = new HashMap<String, String>();
		map.put("name", name);
		map.put("categoryId", categoryId);
		map.put("orderBy", orderBy);
		map.put("minRow", String.valueOf(minRow));
		map.put("maxRow", String.valueOf(maxRow));
		requestModel.api = GET_GAME;
		requestModel.params = map;
		return requestModel;
	}
	/**
	 * 
	 * @param name
	 * @param type
	 * @param parCatId
	 * @param version
	 * @return
	 */
	public static RequestModel getCategoryParams(String name, String parCatId,String language) {
		RequestModel requestModel = new RequestModel();
		final HashMap<String, String> map = new HashMap<String, String>();
		map.put("name", name);
		map.put("type", CATEGORY_TYPE);
		map.put("parentId", parCatId);
		map.put("versionId", VERSION_ID);	
		map.put("language", language);
		requestModel.api = GET_CATEGORY;
		requestModel.params = map;
		return requestModel;
	}
	
	
	/**
	 * 
	 * @param title
	 * @param status
	 * @param categoryID
	 * @param roderBy
	 * @param minRow
	 * @param maxRow
	 * @return
	 */
	public static RequestModel getSubCategoryParams(String title,String categoryID,String versionId, String orderBy,int minRow,int maxRow) {
		if(categoryID!=null /*&& parentCatId!=null*/) {
			RequestModel requestModel = new RequestModel();
			final HashMap<String, String> map = new HashMap<String, String>();
			map.put("title", title);
			map.put("status", "1");
			map.put("categoryId", categoryID);
			map.put("orderBy", orderBy);
			map.put("versionId",versionId);	
			map.put("minRow", String.valueOf(minRow));
			map.put("maxRow", String.valueOf(maxRow));
			requestModel.api = GET_NEWS;
			requestModel.params = map;
			return requestModel;
		}
		return null;
	}
	/**
	 * 
	 * @param versionId
	 * @return
	 */
	public static RequestModel getAdvertiseParams() {
		RequestModel requestModel = new RequestModel();
		final HashMap<String, String> map = new HashMap<String, String>();
		map.put("versionId",VERSION_ID);	
		requestModel.api = GET_ADVERTISE;
		requestModel.params = map;
		return requestModel;
	}
	/**
	 * 
	 * @param act
	 * @param versionId
	 * @param addExpireDate
	 * @param regId
	 * @return
	 */
	public static RequestModel getdeviceConnectParams(Activity act,String regId) {
		TelephonyManager tManager = (TelephonyManager) act.getSystemService(Context.TELEPHONY_SERVICE);
		String deviceIMEI = tManager.getDeviceId();
		String mPhoneNumber = tManager.getLine1Number();
		String PhoneModel = android.os.Build.MODEL;
		String AndroidVersion = android.os.Build.VERSION.RELEASE;
		String versionName ="?";
		try {
			versionName = act.getPackageManager().getPackageInfo(act.getPackageName(), 0).versionName;
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int sdkVersion = android.os.Build.VERSION.SDK_INT;
		RequestModel requestModel = new RequestModel();
		final HashMap<String, String> map = new HashMap<String, String>();
		map.put("deviceImei", deviceIMEI);
		map.put("versionId", VERSION_ID);		
//		map.put("pushRegister", regId);
		map.put("gcmRegister", regId);
		map.put("os", "android" + PhoneModel + " " + AndroidVersion + " " + sdkVersion);
		map.put("mobile", mPhoneNumber);
		map.put("currentVersion", versionName);
		map.put("addExpiredDate", "11/07/2050");
		map.put("key", "123456");
		requestModel.api = DEVICE_CONNECTED;
		requestModel.params = map;
		return requestModel;
	}
	
	/**
	 * 
	 * @param name
	 * @param categoryId
	 * @param orderBy
	 * @param minRow
	 * @param maxRow
	 * @return
	 */
	public static RequestModel getPicturesDetailParams(String name, String categoryId,String orderBy,int minRow,int maxRow) {
		if (categoryId != null /* && parentCatId!=null */) {
			RequestModel requestModel = new RequestModel();
			final HashMap<String, String> map = new HashMap<String, String>();
			map.put("name", name);
			map.put("categoryId", categoryId);
			map.put("orderBy", orderBy);
			map.put("minRow", String.valueOf(minRow));
			map.put("maxRow", String.valueOf(maxRow));
			requestModel.api = GET_IMAGE;
			requestModel.params = map;
			return requestModel;
		}
		return null;
	}
	/**
	 * 
	 * @param name
	 * @param categoryId
	 * @param orderBy
	 * @param minRow
	 * @param maxRow
	 * @return
	 */
	public static RequestModel getAudioParams(String name, String categoryId,String orderBy,int minRow,int maxRow) {
		if (categoryId != null /* && parentCatId!=null */) {
			RequestModel requestModel = new RequestModel();
			final HashMap<String, String> map = new HashMap<String, String>();
			map.put("name", name);
			map.put("categoryId", categoryId);
			map.put("orderBy", orderBy);
			map.put("minRow", String.valueOf(minRow));
			map.put("maxRow", String.valueOf(maxRow));
			requestModel.api = GET_AUDIO;
			requestModel.params = map;
			return requestModel;
		}
		return null;
	}
	
	/**
	 * Gets the download image link.
	 *
	 * @param widthParams the width params
	 * @param heightParams the height params
	 * @param imageId the image id
	 * @return the download image link
	 */
	public static String getDownloadImageLink(int widthParams,int heightParams,String imageId){
		String ret = DOWNLOAD_BASE_URL+"v=0"
						+"&w="+widthParams
						+"&h="+heightParams
						+"&id="+imageId;
		return ret;
	}
	
	public void getpayment(Context act,String versionId,String shortCode,String keyword, String status,String des) {
		TelephonyManager tManager = (TelephonyManager) act.getSystemService(Context.TELEPHONY_SERVICE);
		String deviceIMEI = tManager.getDeviceId();
		String mPhoneNumber = tManager.getLine1Number();
		final HashMap<String, String> map = new HashMap<String, String>();
		map.put("deviceImei", deviceIMEI);
		map.put("versionId", versionId);
		map.put("shortCode", shortCode);
		map.put("keyword", keyword);
		map.put("status", status);
		map.put("mobile", mPhoneNumber);
		map.put("description", des);
		ApiRequest.sendRequest(map, GET_PAYMENT);
	}
	

}
